#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project : python的学习
@File    : 异常.py
@IDE     : PyCharm
@Author  : 春风十里
@Date    : 2023/6/27 15:24

'''


# 模拟用户输入密码
class MyError(Exception):
    def __init__(self, length, min_len):
        self.length = length
        self.min_len = length

    # 设置抛出异常的描述信息
    def __str__(self):
        return "你输入的长度是%s,不能少于%s" % (self.length, self.min_len)


def main():
    try:
        con = input("请输入密码:")
        l = len(con)
        if l < 6:
            raise MyError(l, 6)
    except Exception as ss:
        print(ss)
    else:
        print("您的密码输入完毕")


main()
